package com.hxzy.controller.resourcestore;

import com.github.pagehelper.PageInfo;
import com.hxzy.util.ThreadLocalUtil;
import com.hxzy.common.BaseServlet;
import com.hxzy.dto.ResourceStoreDTO;
import com.hxzy.entity.ResourceStore;
import com.hxzy.service.ResourceStoreService;
import com.hxzy.service.impl.ResourceStoreSeviceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: lqq
 * @Description:
 * @Date: 2022/3/8 19:10
 */
@WebServlet(urlPatterns = "/ResourceStore/search")
public class SearchServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ThreadLocalUtil.threadLocal.get();
        //获取当前登录的用户是谁？
        System.out.println(ThreadLocalUtil.threadLocal.get().toString());
        //1、开启分页
        super.startPage(req);

        try {
            //2、收集参数

            ResourceStoreDTO resourceStoreDTO=super.CollectiongParameterVlues(req,ResourceStoreDTO.class);

            //3、查询数据
            ResourceStoreService Service=new ResourceStoreSeviceImpl();
            List<ResourceStore> search = Service.search(resourceStoreDTO);

            //返回给客户端
            super.render(resp,new PageInfo(search));

        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
